package org.dht.com.msg;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;

/**
 * <p>
 * Java class for Address complex type.
 * 
 * <p>
 * The following schema fragment specifies the expected content contained within
 * this class.
 * 
 * <pre>
 * <complexType name="Address">
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <attribute name="source" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
 *       <attribute name="destination" type="{http://www.w3.org/2001/XMLSchema}string" />
 *     </restriction>
 *   </complexContent>
 * </complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Address")
public class Address {

	/**
	 * Source name
	 */
	@XmlAttribute(required = true)
	protected String source;
	/**
	 * Destination name
	 */
	@XmlAttribute
	protected String destination;

	/**
	 * Builds address by source and destination names
	 * 
	 * @param source
	 *            Source name
	 * @param destination
	 *            Destination name
	 */
	public Address(String source, String destination) {
		this.source = source;
		this.destination = destination;
	}

	/**
	 * Builds an address empty
	 */
	Address() {
	}

	/**
	 * This method is used for knowing if the message is the same source and
	 * destination node
	 * 
	 * @return Returns true if the message is the same source and destination
	 *         node
	 */
	public boolean isMessageFromMySelf() {
		if (source != null && destination != null) {
			return source.equals(destination);
		} else {
			if (source != null) {
				return false;
			} else {
				if (destination != null) {
					return false;
				} else {
					return true;
				}
			}
		}
	}

	/**
	 * Gets the value of the source property.
	 * 
	 * @return possible object is {@link String }
	 * 
	 */
	public String getSource() {
		return source;
	}

	/**
	 * Sets the value of the source property.
	 * 
	 * @param value
	 *            allowed object is {@link String }
	 * 
	 */
	public void setSource(String value) {
		this.source = value;
	}

	/**
	 * Gets the value of the destination property.
	 * 
	 * @return possible object is {@link String }
	 * 
	 */
	public String getDestination() {
		return destination;
	}

	/**
	 * Sets the value of the destination property.
	 * 
	 * @param value
	 *            allowed object is {@link String }
	 * 
	 */
	public void setDestination(String value) {
		this.destination = value;
	}

}
